<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width;" />
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <meta name="format-detection" content="telephone=no" />
    <meta name="format-detection" content="email=no" />
    <title></title>
    <script type="text/javascript" src="plugins/jquery-3.0.0.min.js"></script>
    <script type="text/javascript" src="../common.js"></script>
    <link rel="stylesheet" type="text/css" href="plugins/layer/need/layer.css" />
    <script type="text/javascript" src="plugins/layer/layer.js"></script>
    <script type="text/javascript" src="js/common/common.js"></script>
    <script type="text/javascript" src="js/common/cutscreen.js"></script>
</head>
<body>

</body>
<script type="text/javascript">
    var paper;
    function initPage() {
        paper = GetParpam('paper');
        if(!paper) {
            dataSave('errorContent', "试卷不存在,请重新扫码");
            nextView('view/error.html'); return;
        }
        dataSave('paper', paper);
        var userUuid = dataGet('userUuid');
        var crusrName = dataGet('crusrName');
        var crusrPassword = dataGet('crusrPassword');
        if(!userUuid || !crusrName || !crusrPassword) {
            //用户信息缺失，跳转到登陆页面
            nextView('login.html?paper='+paper); return;
        }
        //自动登陆并判断页面跳转
        var data = {
            crusrName: crusrName,
            crusrPassword: crusrPassword,
            paper: paper
        }
        var url = WEB_URL + "coreUser/login";
        ajaxTool("post",data,url,
            function error(XMLHttpRequest, textStatus, errorThrown,fnErr){
                nextView('login.html?paper='+paper); return;
            },
            function success(odata){
                if(!odata.success) {
                    nextView('login.html?paper='+paper); return;
                }else{
                    dataSave('userUuid', odata.data.crusrUuid);
                    dataSave('crusrName', odata.data.crusrName);
                    dataSave('crusrCode', odata.data.crusrCode);
                    dataSave('crusrPassword', odata.data.crusrPassword);
                    if(odata.code == 2) {
                        nextView('exam.html?paper='+paper);
                    } else if(odata.code == 3) {
                        nextView('view.html?paper='+paper);
                    } else {
                        dataSave('errorContent', "二维码有问题,请重新扫码");
                        nextView('view/error.html');
                    }
                }
            },true
        );
    }
    $(function() {
        initPage();
    });

</script>
</html>